package com.hmjk.health.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewParent;
import android.widget.ListView;

public class InnerListView extends ListView{

	public InnerListView(Context context) {
		super(context);
	}
	
	public InnerListView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	public InnerListView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev){
		switch(ev.getAction()){
		case MotionEvent.ACTION_DOWN:{
		
			setParentScrollable(false);
		}
		break;
		case MotionEvent.ACTION_UP:
		case MotionEvent.ACTION_CANCEL:{
		
			setParentScrollable(true);
		}
		break;
			
		}
		return super.onInterceptTouchEvent(ev);
	}
	
	private void setParentScrollable(boolean enable){
		ViewParent parent = getParent();
		if(parent != null){
			parent.requestDisallowInterceptTouchEvent(!enable);
		}
	}
}
